using System;
using System.ComponentModel;
using System.Xml.Serialization;

namespace com.exceptionalsoftware.spacetime.KML
{
	[Serializable()]
    [XmlType(TypeName = "LocationType")]
    public class Location : ObjectType
	{
        private double altitudeField, latitudeField, longitudeField;

        public Location()
        {
            this.altitudeField = 0;
            this.latitudeField = 0;
            this.longitudeField = 0;
        }

        [XmlElement(ElementName = "altitude", DataType = "double")]
        [DefaultValue(0)]
        public double Altitude
        {
            get { return this.altitudeField; }
            set { this.altitudeField = value; }
        }

        [XmlElement(ElementName = "latitude", DataType = "double")]
        [DefaultValue(0)]
        public double Latitude
        {
            get { return this.latitudeField; }
            set { this.latitudeField = Coordinate.NormalizeToFixedLimits(value, -90, 90); }
        }

        [XmlElement(ElementName = "longitude", DataType = "double")]
        [DefaultValue(0)]
        public double Longitude
        {
            get { return this.longitudeField; }
            set { this.longitudeField = Coordinate.NormalizeToRepeatingLimits(value, -180, 180); }
        }
    }
}